package com.qmyx.supply.admin.controller;

import com.ytjj.qmyx.supplychain.common.api.CommonResult;
import com.ytjj.qmyx.supplychain.common.model.request.BankerInfoRequest;
import com.ytjj.qmyx.supplychain.common.model.request.BrandUpdateNameRequest;
import com.ytjj.qmyx.supplychain.mapper.entity.YxBankerInfo;
import com.ytjj.qmyx.supplychain.service.BankerInfoService;
import com.ytjj.qmyx.supplychain.service.BankerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/bankerInfo")
public class BankerInfoController {
    @Autowired
    private BankerInfoService bankerInfoService;
    @Autowired
    private BankerService bankerService;
    /**
     * 新增店家信息
     * @return
     */
    @PostMapping("/insert")
    public CommonResult insert (@RequestBody YxBankerInfo bankerInfo){
        int count = bankerInfoService.insert(bankerInfo);
        if (count >0){
            return CommonResult.success(count);
        }else {
            return CommonResult.failed();
        }
    }

    /**
     * 查询商家资质信息
     * @return
     *
     */
    @GetMapping("/selectById")
    public CommonResult selectById(){
        BankerInfoRequest bankerInfoRequest = bankerInfoService.selectById();
        return CommonResult.success(bankerInfoRequest);
    }
    /**
     * 修改个人信息
     */
    @PostMapping("/updateById")
    public CommonResult updateById(@Validated @RequestBody YxBankerInfo bankerInfo) {
        int count = bankerInfoService.updateById(bankerInfo);
        if (count > 0){
            return CommonResult.success(count);
        }else {
            return CommonResult.failed();
        }
    }

    /**
     * 重置密码
     * @param request
     * @return
     */
    @PostMapping("/resetPwd")
    public CommonResult resetPwd(@RequestBody BrandUpdateNameRequest request) {
        return bankerService.resetPwd(request);
    }

}
